[java] added annotations and applied format.sh exception classes pt2 #16025
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
🔗 Related Issues
partially fixes #14291
💥 What does this PR do?
same as #16024
🔧 Implementation Notes
This pull request introduces nullability annotations to improve type safety and clarify the handling of nullable values in several exception classes within the Selenium Java codebase. The changes ensure that parameters and fields that can accept or return
null
are explicitly marked as nullable, while the classes themselves are marked as null-safe.Nullability Annotations Added to Exception Classes:
NoSuchSessionException
:@NullMarked
annotation to the class.reason
parameter in constructors as@Nullable
.ScriptTimeoutException
:@NullMarked
annotation to the class.message
andcause
parameters in constructors as@Nullable
.SessionNotCreatedException
:@NullMarked
annotation to the class.msg
andcause
parameters in constructors as@Nullable
.TimeoutException
:@NullMarked
annotation to the class.message
andcause
parameters in constructors as@Nullable
.UnhandledAlertException
:@NullMarked
annotation to the class.alertText
field and themessage
andalertText
parameters in constructors as@Nullable
.getAlertText
method to return@Nullable
.💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
Added JSpecify nullability annotations to exception classes
Marked classes as
@NullMarked
for null safetyAnnotated constructor parameters and fields as
@Nullable
Enhanced type safety for exception handling
Changes diagram
Changes walkthrough 📝
NoSuchSessionException.java
Added nullability annotations to NoSuchSessionException
java/src/org/openqa/selenium/NoSuchSessionException.java
@NullMarked
class annotationreason
constructor parameters as@Nullable
ScriptTimeoutException.java
Added nullability annotations to ScriptTimeoutException
java/src/org/openqa/selenium/ScriptTimeoutException.java
@NullMarked
class annotationmessage
andcause
constructor parameters as@Nullable
SessionNotCreatedException.java
Added nullability annotations to SessionNotCreatedException
java/src/org/openqa/selenium/SessionNotCreatedException.java
@NullMarked
class annotationmsg
andcause
constructor parameters as@Nullable
TimeoutException.java
Added nullability annotations to TimeoutException
java/src/org/openqa/selenium/TimeoutException.java
@NullMarked
class annotationmessage
andcause
constructor parameters as@Nullable
UnhandledAlertException.java
Added nullability annotations to UnhandledAlertException
java/src/org/openqa/selenium/UnhandledAlertException.java
@NullMarked
class annotationalertText
field and constructor parameters as@Nullable
getAlertText
method return type as@Nullable